//
//  LGInspectTimeView.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/3/13.
//

#import "LGInspectSettingTimeView.h"
#import "DatePickerTwoView.h"
@interface LGInspectSettingTimeView()<DatePickerViewDelegate>
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIButton *titleBtn;
/**   */
@property (nonatomic , strong)UIButton *dateBtn;

@end

@implementation LGInspectSettingTimeView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithString:@"#F9F9F9"];
        [self addSubview:self.baseView];
        [self.baseView addSubview:self.titleBtn];
        [self.baseView addSubview:self.dateBtn];
    }
    return self;
}

-(void)setVisitdate:(NSString *)visitdate{
    _visitdate = visitdate;
    [self.dateBtn setTitle:visitdate forState:UIControlStateNormal];
    [self.dateBtn setButtonInsetsStyle:LGButtonInsetsStyleRight marginSpace:5];
}


-(void)selectInspectDate{
    DatePickerTwoView *pickerView = [[DatePickerTwoView alloc]initWithFrame:CGRectMake(0, 0, Screen_W, Screen_H)];
    pickerView.currentDate = self.visitdate;
    pickerView.title = @"复诊时间";
    pickerView.delegate = self;
    [[UIApplication sharedApplication].keyWindow addSubview:pickerView];
}

-(void)sendSelectDate:(NSString *)date index:(NSInteger)index{
    self.visitdate = date;
}


-(UIView *)baseView{
    if(!_baseView){
        _baseView = [[UIView alloc] initWithFrame:CGRectMake(viewPix(16), viewPix(16), Screen_W-viewPix(32), viewPix(56))];
        [_baseView setShadoWithColor:@"#B3C5D9" offset:CGSizeMake(0, 2) opacity:0.15 radius:10];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UIButton *)titleBtn{
    if(!_titleBtn){
        _titleBtn = [UIButton buttonWithTitle:@"复诊时间" titleFont:LGFontWeight(16, UIFontWeightMedium) textColor:@"#333333" imageName:@"复诊计划-检查时间"];
        _titleBtn.frame = CGRectMake(viewPix(12), 0, viewPix(120), viewPix(56));
        _titleBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        _titleBtn.titleEdgeInsets = UIEdgeInsetsMake(0, viewPix(6), 0, 0);
    }
    return _titleBtn;
}

-(UIButton *)dateBtn{
    if(!_dateBtn){
        _dateBtn = [UIButton buttonWithTitle:@" " titleFont:LGFont(16) textColor:@"#000000" imageName:@"grayTip12"];
        _dateBtn.frame = CGRectMake(Screen_W-viewPix(32)-viewPix(12)-viewPix(180), 0, viewPix(180), viewPix(56));
        _dateBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        [_dateBtn setButtonInsetsStyle:LGButtonInsetsStyleRight marginSpace:5];
        [_dateBtn addTarget:self action:@selector(selectInspectDate) forControlEvents:UIControlEventTouchUpInside];
    }
    return _dateBtn;
}

@end
